{block name=classterm-tree-list}
{if $classterm_list}
	{assign var=weekdays value=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday', 'Saturday']}
	{foreach from=$classterm_list key=kloc item=location}
		<div class="comm-cat">
			<a href="javascript:void(0)"><span class="show-hide glyphicon glyphicon-plus"></span></a>
			<label for="loc{$kloc}">{$location.location_name}</label>
			<input class="chckbx pull-right" type="checkbox" id="loc{$kloc}" name="location[{$kloc}]">
			{foreach $weekdays as $weekday}
				{assign var=classes value=$location.weekdays.$weekday}
				{if $classes}
					<div class="comm-cat" style="display:none;">
						<a href="javascript:void(0)"><span class="show-hide glyphicon glyphicon-plus"></span></a>
						<label for="loc{$kloc}_{$weekday}">{$weekday}</label>
						<input class="chckbx pull-right" type="checkbox" id="loc{$kloc}_{$weekday}" name="weekday[{$kloc}]">
						{foreach from=$classes key=classoid item=class}
							<div class="comm-class" style="display:none;">
								<label for="{$class.class_url}">{$class.class_start_time|date_format:"%I:%M%p"|lower} - {$class.class_end_time|date_format:"%I:%M%p"|lower} | {$class.agegroup_name}</label>
								<input class="chckbx pull-right" type="checkbox" id="{$class.class_url}" name="classes[{$class.class_object_id}]">
							</div>
						{/foreach}
					</div>
				{/if}
			{/foreach}
		</div>
	{/foreach}
{else}
	<div class="well">
		<h3>该学期没有课程。</h3>
	</div>
{/if}
{/block} 

	<script type="text/javascript">
	 
	$('.chckbx').click(function() {
	 	if($(this).is(':checked')){ 
	 			$(this).parent().children('div').find('input[type="checkbox"]').val('1').attr('checked','checked');
	 	}else{ 
	 			$(this).parent().children('div').find('input[type="checkbox"]').val('0').removeAttr('checked');
	 	}
	});

	$('.show-hide').click(function() {
	 	if( $(this).hasClass('glyphicon-minus')){
	 		$(this).removeClass('glyphicon-minus').addClass('glyphicon-plus'); 
 			$(this).closest('div').find('div').hide();
	 	}else{ 
 			$(this).removeClass('glyphicon-plus').addClass('glyphicon-minus'); 
 			$(this).closest('div').children('div').show();
	 	}
	});
 	
 	</script>